﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;

using Ivy.Common.Framework.Base;
using Ivy.Common.Framework.GeneralUtility;

using Ivy.UserManagement.Entity;
using Ivy.UserManagement.BusinessLogic;

using Ivy.SiteAdministration.Entity;
using Ivy.SiteAdministration.BusinessLogic;

using Ivy.SiteGeneralBasic.Entity;
using Ivy.SiteGeneralBasic.BusinessLogic;

using FrameworkIvy.App_Code;

namespace FrameworkIvy.UserControls
{
    public partial class ProjectMemberRegistrationControl : System.Web.UI.UserControl
    {
        #region  Variable & constant
        // All constants and local variable should be declared here
        // TRY NOT TO CREATE PUBLIC VARIABLES INSTEAD USE PROPERTIES FOR THAT PURPOSE.
        // Variable naming convention :- 
        // The naming should be self explanatory, make it long to explain the purpose 
        // and use PascalCase to seperate words as shown in the example below.
        // DO NOT USE ANY ABBRIVIATION use full word (like "Customer" instead of "Cust"
        // Naming convention for all local variable should start with underscore "_"
        // Naming convention for all local constant should start with "_The"
        // Example :    string _CustomerCode = string.Empty;
        // Example :    const string _TheDefaultSmtpServer = "DefaultSmtpServer";
        // ==================== START YOUR CODE FROM NEXT LINE ========================

        //Needed for Authorization logic.
        //For Screens that can be accessed by any users, even guest users, the default Page level IsAnonymousAccess value will be TRUE.
        //But for Screens with access restriction the IsAnonymousAccess value will be FALSE.
        const string _TheDefaultUserContextSessionVariableName = "UserContext";
        const string _TheDefaultValueForProjectMembershipSessionVariableName = "ProjectMembershipSession";
        //const string constCultureInfo = "CultureInfo";
        //Needed for Authorization logic.
        //For Screens that are Non-Organization specific related (Generic) Activities, the default Page level IsNonOrganizationSpecificActivity value will be TRUE.
        //But for Screens with Activities related to Organization the IsNonOrganizationSpecificActivity value will be FALSE.
        bool IsAnonymousAccess = false;
        bool IsNonOrganizationSpecificActivity = true;

        //Needed for Authorization logic.
        //For Screens with multiple activities, the default ActivityCode value will be [string.Empty], it will be initialized dynamically with query string from the calling event.
        //But for single ActivityCode like only view for reports or only insert etc. we need to assign the specific value below.
        //And for any Screen which only for display by any registered user the ActivityCode value will be [SystemActivities.RetrieveBlogs]
        //Please ensure to make an entry into the App_Code -> ApplicationKeyWords.cs file under the class SystemActivities with respective ActivityCode.
        string _CurrentActivityCode = string.Empty;

        //Needed for Screen initialization logic.
        //For Screens with multiple ScreenActionMode, the default value will be [ScreenActionMode.UnKnown], it will be initialized dynamically with query string from the calling event.
        //but for single ScreenActionMode like only view for reports or only insert etc. we need to assign the specific value below.
        ScreenActionMode _CurrentScreenActionMode = ScreenActionMode.Display;

        #endregion  Variable & constant

        #region Constructor & Destructor
        // Generally not needed in UI layer.
        // Cut and Copy the default constructor for the class inside this region.
        // Generally not required in UI layer.
        // Example:
        // public SampleClassTemplate()
        // {

        // }
        // ==================== START YOUR CODE FROM NEXT LINE ========================
        //public SampleAspxUIClassTemplate()
        //{
        //}

        #endregion Constructor & Destructor

        #region Properties
        // Any value/variable that needs to be exposed outside the class we need to create a property.
        // Avoid creating public variables rather create public properties.
        // UI layer may have public custom properties. these are very handy for User Controls.
        // Property naming convention :- Properties will be exposed outside the class, 
        // the naming should be self explanatory, make it long to explain the purpose 
        // and use PascalCase to seperate words as shown in the example below.
        // DO NOT USE ANY ABBRIVIATION use full word (like "Customer" instead of "Cust"
        // All properties should have a corresponding local variable 
        // and the property name and local variable name should match.
        // Example :
        // public string CustomerCode
        // {
        //     get
        //     {
        //         return _CustomerCode;
        //     }
        //     set
        //     {
        //         _CustomerCode = value;
        //     }
        // }
        // ==================== START YOUR CODE FROM NEXT LINE ========================

         public bool AnonymousAccess
         {
             get
             {
                 return IsAnonymousAccess;
             }
             set
             {
                 IsAnonymousAccess = value;
             }
         }
         
        #endregion Properties

        #region Events
        // Generally UI layer will have public events.
        // Cut and Copy the default generated events for the class inside this region.
        // ==================== START YOUR CODE FROM NEXT LINE ========================

        protected void Page_Load(object sender, EventArgs e)
        {
            try //All events in pages or user control should have try{} catch {} block.
            {
                if (!Page.IsPostBack)
                {
                    //First check if the current logged in user is having proper role/authorization to access this page or not.
                    if (IsUserAutherization())
                    {
                        //TODO - Your code to display the initial layout/data etc.
                        InitializeScreen();
                    }
                    else
                    {
                        //TODO - Your code to redirect page to "NOT AUTHORIZED" page or any other page as required by the business logic.
                        //Response.Redirect("../BasicPages/UnAuthorizedGuest.aspx");
                        Response.Redirect("../BasicPage/UnAuthorizedMember.aspx");
                    }
                }
            }
            catch (Exception ex)
            {
                UIExceptionUtility.ExceptionHandler(ex, Server.MapPath("~/"));
            }
        }

        protected void btnSaveProjectMember_Click(object sender, EventArgs e)
        {
            try
            {
                UserManagementBus _UserManagementBus = new UserManagementBus();
                ProjectMemberMaster _ProjectMemberMaster;

                if (ViewState[_TheDefaultValueForProjectMembershipSessionVariableName] != null) //This session variable is created during screen initialization. If not present there is an error.
                {
                    _ProjectMemberMaster = (ProjectMemberMaster)ViewState[_TheDefaultValueForProjectMembershipSessionVariableName];
                }
                else
                {
                    //Generally this set should never get executed. 
                    //As this Session object should always be created once during screen initialization. If not present there is an error.
                    _ProjectMemberMaster = new ProjectMemberMaster();
                }
                TranslateProjectMemberMasterUIControlsToEntity(_ProjectMemberMaster);
                User _User = SessionUtility.GetCurrentLoginUser();
                if (_ProjectMemberMaster.EntityState == EntityState.New)
                {
                    //Insert Logic
                    if (_User != null)
                    {
                        _ProjectMemberMaster.Sys_CreatedByID = _User.UserPersonKey.ToString();
                    }
                    else
                    {
                        _ProjectMemberMaster.Sys_CreatedByID = "1";
                    }
                    if (_UserManagementBus.SaveProjectMember(_ProjectMemberMaster))
                    {
                        if (IsAnonymousAccess)
                        {
                            _UserManagementBus.SendProjectMemberRegistrationNotificationEmail(_ProjectMemberMaster);
                        }
                        ViewState[_TheDefaultValueForProjectMembershipSessionVariableName] = _ProjectMemberMaster;
                        //TODO: Successfully inserted new record message
                        this.ProjectMemberDetailsModalPopupExtender.Show();
                    }

                }
                if(_ProjectMemberMaster.EntityState == EntityState.Changed)
                {
                    //Update Logic
                    _ProjectMemberMaster.Sys_ModifiedByID = _User.UserPersonKey.ToString();
                    if (_UserManagementBus.UpdateRegisteredProjectMember(_ProjectMemberMaster))
                    {
                        //TODO: Successfully updated existing record message
                        this.ProjectMemberDetailsModalPopupExtender.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                //ExceptionUtility.ExceptionHandler(ex, Server.MapPath("~/"));
            }
        }
        protected void btnProjectMemberSuccessOk_Click(object sender, EventArgs e)
        {
            User _User = SessionUtility.GetCurrentLoginUser();
            if (_User != null)
            {
                this.ProjectMemberDetailsModalPopupExtender.Hide();
            }
            else
            {
                this.ProjectMemberDetailsModalPopupExtender.Hide();
                ViewState[_TheDefaultValueForProjectMembershipSessionVariableName] = null;
                Response.Redirect("~/Default.aspx");
            }
        }
        #endregion Events

        #region Public Methods
        // UI layer may have public custom Methods. These are very handy for User Controls.
        // Any method that needs to be exposed outside the class will be created inside this region.
        // Public Method naming convention :- Public Method will be exposed outside the class, 
        // The input and output parameters are also going to be exposed outside the class
        // the naming should be self explanatory, make it long to explain the purpose 
        // and use PascalCase to seperate words as shown in the example below.
        // DO NOT USE ANY ABBRIVIATION use full word (like "Customer" instead of "Cust"
        // Example :
        // public bool RegisterNewCustomer(Customer Customer)
        // {
        //     bool IsCustomerDataSaved = false;
        //     //TO DO logic to save data
        //     IsCustomerDataSaved = InsertCustomerDataUsingDao(Customer);
        //     return IsCustomerDataSaved;
        // }
        // ==================== START YOUR CODE FROM NEXT LINE ========================
       

        #endregion Public Methods

        #region Private Methods
        // All local class level methods will be inside this region. Mostly these are helper methods.
        // Private Method naming convention :- The naming should be self explanatory, 
        // make it long to explain the purpose and use PascalCase to seperate words as shown in the example below.
        // DO NOT USE ANY ABBRIVIATION use full word (like "Customer" instead of "Cust"
        // Input parameter will have a "p" as prefix. 
        // This will help the parameter variable that the value is originated outside this private method.
        // Example :
        // public bool InsertCustomerDataUsingDao(Customer pCustomer)
        // {
        //     bool IsCustomerDataInsertedSuccessfully = false;
        //     //TO DO logic to save data
        //     //....
        //     //....
        //     return IsCustomerDataInsertedSuccessfully;
        // }
        // ==================== START YOUR CODE FROM NEXT LINE ========================


        /// <summary>
        /// This method is to check if the current logged in user is having proper role/authorization to access this page or not.
        /// </summary>
        private bool IsUserAutherization()
        {
            bool _IsUserAutherization = false;
            //TODO - Your code to check authorization goes here.


            //Check if the Screen has Access Restriction.
            if (IsAnonymousAccess)
            {
                _IsUserAutherization = true; //by default the activity can be executed by any person even guest user.
            }
            else
            {
                User _User = SessionUtility.GetCurrentLoginUser();
                if (_User != null)
                {
                    ////Check if the Screen Activity is a Non-Organization specific activity then the  _UserDefaultOrzanization code will be -1 (SYSTEM)
                    Sys_OrganizationMaster _UserDefaultOrzanization;
                    _UserDefaultOrzanization = SessionUtility.GetCurrentLoginUserOrzanization();
                    UserManagementBus _UserManagementBus = new UserManagementBus();

                    if (IsNonOrganizationSpecificActivity)
                    {
                        SiteAdministrationBus _SiteAdministrationBus = new SiteAdministrationBus();
                        //Set _UserDefaultOrzanization = System/-1
                        _UserDefaultOrzanization = _SiteAdministrationBus.GetSys_OrganizationMasterByKey(-1);
                    }

                    if (_UserDefaultOrzanization != null)
                    {
                        //Check if QueryString for ActivityCode is supplied, then this Screen is for multiple Activities 
                        //and the current instance ActivityCode is supplied by the QueryString. 
                        //In that case we need to overwrite the default ActivityCode from string.Empty to the QueryString value.
                        if (!string.IsNullOrEmpty(Request.QueryString["ActivityCode"]))
                        {
                            _CurrentActivityCode = Request.QueryString["ActivityCode"].ToString();
                        }
                        //Get the Authorization details for the current logged in user and the the role
                        _IsUserAutherization = _UserManagementBus.IsAcitivityAuthorized(_UserDefaultOrzanization.OrganizationCode, _CurrentActivityCode, _User.UserLoginId);
                    }
                }
            }
            return _IsUserAutherization;
        }

        /// <summary>
        /// This method is to clear all UI controls which are data binded.
        /// </summary>
        private void ClearScreen()
        {
        }

        /// <summary>
        /// This method is to bind all the UI control like dropdown list or list box etc with the required initial data, 
        /// </summary>
        private void FillLoadLookUpData()
        {
        }

        /// <summary>
        /// This method is applicable only for Screens with multiple ScreenActionMode, where QuerySting is Involved
        /// </summary>

        private void InitializeScreen()
        {
            //Check if QueryString for ScreenActionMode is supplied, then this Screen is with multiple ScreenActionMode 
            //and the current instance ScreenActionMode is supplied by the QueryString. 
            //In that case we need to overwrite the default ScreenActionMode from ScreenActionMode.UnKnown to the QueryString value.
            if (!string.IsNullOrEmpty(Request.QueryString["ScreenMode"]))
            {
                _CurrentScreenActionMode = (ScreenActionMode)Enum.Parse(typeof(ScreenActionMode), Request.QueryString["ScreenMode"].ToString());
                //Check if the Screen is a single ScreenActionMode 
                if (_CurrentScreenActionMode != ScreenActionMode.UnKnown)
                {
                    //TODO: Logic to Set the screen controls to respective action mode. Example :-
                    //In case of [New] mode the screen should be clear of all existing data.
                    //In case of [Edit] mode the screen should be filled with the existing record that is to be edited.

                    UserManagementBus _UserManagementBus = new UserManagementBus();
                    SiteAdministrationBus _SiteAdministrationBus = new SiteAdministrationBus();
                    if (_CurrentScreenActionMode == ScreenActionMode.New)
                    {
                        if (!IsNonOrganizationSpecificActivity)
                        {
                            ////Check for any other QueryString as per business logic. Example:-
                            //if (!string.IsNullOrEmpty(Request.QueryString["OrganizationKey"]))
                            //{
                            //    Sys_OrganizationMaster _UserDefaultOrzanization = _SiteAdministrationBus.GetSys_OrganizationMasterByKey(Convert.ToInt32(Request.QueryString["OrganizationKey"].ToString()));
                            //    if (_UserDefaultOrzanization != null)
                            //    {
                            //        User _CurrentUser = SessionUtility.GetCurrentLoginUser();
                            //        <EntityName> _<EntityName> = new <EntityName>();
                            //        _<EntityName>.Sys_CreatedByID = _CurrentUser.UserPersonKey.ToString();
                            //        _<EntityName>.Sys_OrganizationID = _UserDefaultOrzanization.OrganizationID;
                            //        ViewState[_TheDefaultValueFor<EntityName>] = _<EntityName>;
                            //    }
                            //}     
                            //////OR if no QueryString involved then create a new instance of the entity and place it in ViewState[]
                            ////User _CurrentUser = SessionUtility.GetCurrentLoginUser();
                            ////<EntityName> _<EntityName> = new <EntityName>();
                            ////_<EntityName>.Sys_CreatedByID = _CurrentUser.UserPersonKey.ToString();
                            ////_<EntityName>.Sys_OrganizationID = _UserDefaultOrzanization.OrganizationID;
                            ////ViewState[_TheDefaultValueFor<EntityName>] = _<EntityName>;
                            //else
                            //{
                            //    Exception ex = new Exception("This screen is Organization specific activity, Please supply OrganizationKey as QueryString");
                            //    throw ex;
                            //}
                        }
                        else
                        {
                            //Check for any other QueryString as per business logic. Example:-
                            Sys_OrganizationMaster _UserDefaultOrzanization = _SiteAdministrationBus.GetSys_OrganizationMasterByKey(-1);
                            if (_UserDefaultOrzanization != null)
                            {
                                User _CurrentUser = SessionUtility.GetCurrentLoginUser();
                                ProjectMemberMaster _ProjectMemberMaster = new ProjectMemberMaster();
                                //_<EntityName>.Sys_CreatedByID = _CurrentUser.UserPersonKey.ToString();
                                //_<EntityName>.Sys_OrganizationID = _UserDefaultOrzanization.OrganizationID;
                                ViewState[_TheDefaultValueForProjectMembershipSessionVariableName] = _ProjectMemberMaster;
                                this.DivBackToPreviousProjectMemberSummary.Visible = true;
                            }
                        }
                    }
                    if (_CurrentScreenActionMode == ScreenActionMode.Edit)
                    {
                        if (!IsNonOrganizationSpecificActivity)
                        {
                            //Check for any other QueryString as per business logic. Example:-
                            if (!string.IsNullOrEmpty(Request.QueryString["OrganizationKey"]))
                            {
                                Sys_OrganizationMaster _UserDefaultOrzanization = _SiteAdministrationBus.GetSys_OrganizationMasterByKey(Convert.ToInt32(Request.QueryString["OrganizationKey"].ToString()));
                                if (_UserDefaultOrzanization != null)
                                {
                                    User _CurrentUser = SessionUtility.GetCurrentLoginUser();
                                    //<ModuleName>Bus _<ModuleName>Bus = new <ModuleName>Bus();
                                    ProjectMemberMaster _ProjectMemberMaster = _UserManagementBus.GetProjectMemberByPrimaryKey(Convert.ToInt32(Request.QueryString["ProjectMemberKey"].ToString()));
                                    _ProjectMemberMaster.Sys_ModifiedByID = _CurrentUser.UserPersonKey.ToString();
                                    ViewState[_TheDefaultValueForProjectMembershipSessionVariableName] = _ProjectMemberMaster;
                                }
                            }
                            ////OR if no QueryString involved then create a new instance of the entity and place it in ViewState[]

                            //User _CurrentUser = SessionUtility.GetCurrentLoginUser();
                            //<EntityName> _<EntityName> = _<ModuleName>Bus.Get<EntityName>ByKey(Convert.ToInt32(Request.QueryString["<EntityName>Key"].ToString()));
                            //_<EntityName>.Sys_ModifiedByID = _CurrentUser.UserPersonKey.ToString();
                            //ViewState[_TheDefaultValueFor<EntityName>] = _<EntityName>;
                            else
                            {
                                Exception ex = new Exception("This screen is Organization specific activity, Please supply OrganizationKey as QueryString");
                                throw ex;
                            }
                        }
                        else
                        {
                            //Check for any other QueryString as per business logic. Example:-
                            Sys_OrganizationMaster _UserDefaultOrzanization = _SiteAdministrationBus.GetSys_OrganizationMasterByKey(-1);
                            if (_UserDefaultOrzanization != null)
                            {
                                User _CurrentUser = SessionUtility.GetCurrentLoginUser();
                                //<ModuleName>Bus _<ModuleName>Bus = new <ModuleName>Bus();
                                ProjectMemberMaster _ProjectMemberMaster = _UserManagementBus.GetProjectMemberByPrimaryKey(Convert.ToInt32(Request.QueryString["ProjectMemberKey"].ToString()));
                                _ProjectMemberMaster.Sys_ModifiedByID = _CurrentUser.UserPersonKey.ToString();
                                ViewState[_TheDefaultValueForProjectMembershipSessionVariableName] = _ProjectMemberMaster;
                                this.DivBackToPreviousProjectMemberSummary.Visible = true;
                            }
                        }
                    }
                    if (_CurrentScreenActionMode == ScreenActionMode.Display)
                    {
                        if (!IsNonOrganizationSpecificActivity)
                        {
                            ////Check for any other QueryString as per business logic. Example:-
                            //if (!string.IsNullOrEmpty(Request.QueryString["OrganizationKey"]))
                            //{
                            //    Sys_OrganizationMaster _UserDefaultOrzanization = _SiteAdministrationBus.GetSys_OrganizationMasterByKey(Convert.ToInt32(Request.QueryString["OrganizationKey"].ToString()));
                            //    if (_UserDefaultOrzanization != null)
                            //    {
                            //        <ModuleName>Bus _<ModuleName>Bus = new <ModuleName>Bus();
                            //        <EntityName> _<EntityName> = _<ModuleName>Bus.Get<EntityName>ByKey(Convert.ToInt32(Request.QueryString["<EntityName>Key"].ToString()));
                            //        ViewState[_TheDefaultValueFor<EntityName>] = _<EntityName>;
                            //    }
                            //}
                            //////OR if no QueryString involved then create a new instance of the entity and place it in ViewState[]
                            ////<ModuleName>Bus _<ModuleName>Bus = new <ModuleName>Bus();
                            ////<EntityName> _<EntityName> = _<ModuleName>Bus.Get<EntityName>ByKey(Convert.ToInt32(Request.QueryString["<EntityName>Key"].ToString()));
                            ////ViewState[_TheDefaultValueFor<EntityName>] = _<EntityName>;
                            //{
                            //    Exception ex = new Exception("This screen is Organization specific activity, Please supply OrganizationKey as QueryString");
                            //    throw ex;
                            //}
                        }
                        else
                        {
                            ////Check for any other QueryString as per business logic. Example:-
                            //Sys_OrganizationMaster _UserDefaultOrzanization = _SiteAdministrationBus.GetSys_OrganizationMasterByKey(-1);
                            //if (_UserDefaultOrzanization != null)
                            //{
                            //    <ModuleName>Bus _<ModuleName>Bus = new <ModuleName>Bus();
                            //    <EntityName> _<EntityName> = _<ModuleName>Bus.Get<EntityName>ByKey(Convert.ToInt32(Request.QueryString["<EntityName>Key"].ToString()));
                            //    ViewState[_TheDefaultValueFor<EntityName>] = _<EntityName>;
                            //}
                        }
                    }
                }
            }
            else
            {
                if (_CurrentScreenActionMode != ScreenActionMode.Display)
                {
                    if (!IsNonOrganizationSpecificActivity)
                    {
                        ////Check for any other QueryString as per business logic. Example:-
                        //if (!string.IsNullOrEmpty(Request.QueryString["OrganizationKey"]))
                        //{
                        //    Sys_OrganizationMaster _UserDefaultOrzanization = _SiteAdministrationBus.GetSys_OrganizationMasterByKey(Convert.ToInt32(Request.QueryString["OrganizationKey"].ToString()));
                        //    if (_UserDefaultOrzanization != null)
                        //    {
                        //        <ModuleName>Bus _<ModuleName>Bus = new <ModuleName>Bus();
                        //        <EntityName> _<EntityName> = _<ModuleName>Bus.Get<EntityName>ByKey(Convert.ToInt32(Request.QueryString["<EntityName>Key"].ToString()));
                        //        ViewState[_TheDefaultValueFor<EntityName>] = _<EntityName>;
                        //    }
                        //}
                        //////OR if no QueryString involved then create a new instance of the entity and place it in ViewState[]
                        ////<ModuleName>Bus _<ModuleName>Bus = new <ModuleName>Bus();
                        ////<EntityName> _<EntityName> = _<ModuleName>Bus.Get<EntityName>ByKey(Convert.ToInt32(Request.QueryString["<EntityName>Key"].ToString()));
                        ////ViewState[_TheDefaultValueFor<EntityName>] = _<EntityName>;
                        //{
                        //    Exception ex = new Exception("This screen is Organization specific activity, Please supply OrganizationKey as QueryString");
                        //    throw ex;
                        //}
                    }
                    else
                    {
                        ////Check for any other QueryString as per business logic. Example:-
                        //Sys_OrganizationMaster _UserDefaultOrzanization = _SiteAdministrationBus.GetSys_OrganizationMasterByKey(-1);
                        //if (_UserDefaultOrzanization != null)
                        //{
                        //    <ModuleName>Bus _<ModuleName>Bus = new <ModuleName>Bus();
                        //    <EntityName> _<EntityName> = _<ModuleName>Bus.Get<EntityName>ByKey(Convert.ToInt32(Request.QueryString["<EntityName>Key"].ToString()));
                        //    ViewState[_TheDefaultValueFor<EntityName>] = _<EntityName>;
                        //}
                    }
                }
            }

            ClearScreen();
            FillLoadLookUpData();
            GetProjectMembershipJoiningDate();
            if (_CurrentScreenActionMode == ScreenActionMode.Edit || _CurrentScreenActionMode == ScreenActionMode.Display)
            {
                ProjectMemberMaster _ProjectMemberMaster = (ProjectMemberMaster)ViewState[_TheDefaultValueForProjectMembershipSessionVariableName];
                TranslateProjectMemberMasterEntityToUIControls(_ProjectMemberMaster);
            }
            //TODO: rest of the display logic code
        }
        /// <summary>
        /// This method is to copy the entity properties that need to be displayed in the UI controls to the UI control.
        /// Example - [pUser] is an instance of an entity and is filled with specific USER data.
        /// and this user instance is to be displayed is an UI control text boxes.
        /// A sample code will look like the following:
        ///  this.txtFirstName.Text = pUser.UserFirstName; 
        ///  this.txtLastName.Text  = pUser.UserLastName; 
        ///  this.txtLoginId.Text   = pUser.UserLoginID;
        /// </summary>
        
        private void GetProjectMembershipJoiningDate()
        {
            this.txtDateJoining.Text = DateTime.Now.ToString("dd-MM-yyyy");
        }
        private void TranslateProjectMemberMasterEntityToUIControls(ProjectMemberMaster pProjectMemberMaster)
        {
            this.txtFirstName.Text = pProjectMemberMaster.ProjectMemberFirstName;
            this.txtLastName.Text = pProjectMemberMaster.ProjectMemberLastName;
            this.txtPrimaryEmailId.Text = pProjectMemberMaster.ProjectMemberPrimaryEmailID;
            this.txtCodePlexId.Text = pProjectMemberMaster.ProjectMemberCodePlexID;
            this.txtSkypeId.Text = pProjectMemberMaster.ProjectMemberSkypeID;
            this.txtMicrosoftId.Text = pProjectMemberMaster.ProjectMemberMicrosoftID;
            this.txtGoogleId.Text = pProjectMemberMaster.ProjectMemberGoogleID;
            this.txtTimeZoonReference.Text = pProjectMemberMaster.ProjectMemberTimeZoneReference;
            this.txtTimeZoonName.Text = pProjectMemberMaster.ProjectMemberTimeZoneName;
            this.txtTimeZoonAbbreviation.Text = pProjectMemberMaster.ProjectMemberTimeZoneAbbreviation;
            this.txtCountryName.Text = pProjectMemberMaster.ProjectMemberCountryName;
            this.txtCityName.Text = pProjectMemberMaster.ProjectMemberCityName;
            if (pProjectMemberMaster.ProjectMemberDateOfJoining != null)
            {
                this.txtDateJoining.Text = Convert.ToString(pProjectMemberMaster.ProjectMemberDateOfJoining.Value.ToString("dd/MM/yyyy"));
            }
            else
            {
                this.txtDateJoining.Text = string.Empty;
            }
            if (pProjectMemberMaster.ProjectMemberIsMemberOfFacebook == true)
            {
                this.chkIsMemberOfFacebook.Checked = true;
            }
            else
            {
                this.chkIsMemberOfFacebook.Checked = false;
            }
        }

        /// <summary>
        /// This method is to copy the user entered data from the UI controls to the entity instance that will be used to sent the entity to any other layer.
        /// Example - [pUser] is an instance of an entity and is to be filled with specific USER data that has been captured in the screen.
        /// A sample code will look like the following:
        ///  pUser.UserFirstName = this.txtFirstName.Text; 
        ///  pUser.UserLastName  = this.txtLastName.Text; 
        ///  pUser.UserLoginID   = this.txtLoginId.Text; 
        /// </summary>
        private void TranslateProjectMemberMasterUIControlsToEntity(ProjectMemberMaster pProjectMemberMaster)
        {
            pProjectMemberMaster.ProjectMemberUserKey = 1;
            pProjectMemberMaster.ProjectMemberFirstName = this.txtFirstName.Text;
            pProjectMemberMaster.ProjectMemberLastName = this.txtLastName.Text;
            pProjectMemberMaster.ProjectMemberPrimaryEmailID = this.txtPrimaryEmailId.Text;
            pProjectMemberMaster.ProjectMemberCodePlexID = this.txtCodePlexId.Text;
            pProjectMemberMaster.ProjectMemberSkypeID = this.txtSkypeId.Text;
            pProjectMemberMaster.ProjectMemberMicrosoftID = this.txtMicrosoftId.Text;
            pProjectMemberMaster.ProjectMemberGoogleID = this.txtGoogleId.Text;
            pProjectMemberMaster.ProjectMemberTimeZoneReference = this.txtTimeZoonReference.Text;
            pProjectMemberMaster.ProjectMemberTimeZoneName = this.txtTimeZoonName.Text;
            pProjectMemberMaster.ProjectMemberTimeZoneAbbreviation = this.txtTimeZoonAbbreviation.Text;
            pProjectMemberMaster.ProjectMemberCountryName = this.txtCountryName.Text;
            pProjectMemberMaster.ProjectMemberCityName = this.txtCityName.Text;

            if (!string.IsNullOrEmpty(txtDateJoining.Text.Trim()))
            {
                pProjectMemberMaster.ProjectMemberDateOfJoining = DateTimeUtility.ConvertStringToDateTime(this.txtDateJoining.Text, InputDateTimeFormat.DD_MM_YYYY);
            }
            else
            {
                pProjectMemberMaster.ProjectMemberDateOfJoining = null;
            }
            if (chkIsMemberOfFacebook.Checked == true)
            {
                pProjectMemberMaster.ProjectMemberIsMemberOfFacebook = true;
            }
            else
            {
                pProjectMemberMaster.ProjectMemberIsMemberOfFacebook = false;
            }
        }
        #endregion Private Methods
    }
}